﻿Imports System.Windows.Forms

Public Class SaisieNouveauVaccin_DLG

    Private _ctrl As SaisieNouveauVaccin_CTRL



    Public Sub New(ByVal ctrl As SaisieNouveauVaccin_CTRL)
        InitializeComponent()
        _ctrl = ctrl
    End Sub

    Private Function isSaisieOK() As Boolean
        isSaisieOK = True
        With ErrorProviderSaisieNouveauVaccin
            .SetError(TXTNomVaccin, "")
            .SetError(TXTPeriodeValidite, "")
            If TXTNomVaccin.Text = "" Then
                .SetError(TXTNomVaccin, "Veuillez saisir un nom pour le nouveau vaccin")
                isSaisieOK = False
            End If
            Dim periodeValidite As Integer
            If Not (Integer.TryParse(TXTPeriodeValidite.Text, periodeValidite) AndAlso periodeValidite <> 0) Then
                .SetError(TXTPeriodeValidite, "Veuillez un nombre de mois")
                isSaisieOK = False
            End If
        End With
    End Function

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNOk.Click
        If isSaisieOK() Then
            Me.DialogResult = System.Windows.Forms.DialogResult.OK
            Me.Close()
        End If

    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTnAnnuler.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

End Class
